<template>
  <section class="oa-form__table">
    <h5>{{ approve.name }}</h5>
    <table cellpadding="0" cellspacing="0">
      <tr v-if="$route.query.from != 'new'">
        <td>事务编号</td>
        <td>
          {{ approve.name }}
          <span v-if="approve && approve.code">{{ approve.code }}</span>
        </td>
      </tr>
      <tr>
        <td>流程名称</td>
        <td>
          <span v-if="$route.query.from == 'new'">新建{{ approve.name }}</span>
          <span v-else>
            {{ approve.approve_name }}
          </span>
        </td>
      </tr>
      <tr>
        <td>申请事由</td>
        <td :title="reason"><el-input placeholder="申请事由" type="textarea" v-model="reason" :disabled="$route.query.from != 'new'"/></td>
      </tr>
    </table>
    <h3 class="oa-form__table-title">
      <span v-if="$route.query.from === 'new'">{{ approve.name }}</span>
      <span v-else>
        {{ approve.approve_name }}
      </span>
    </h3>
     <table class="achievement__tab" border="1">
      <tr class="border_0">
        <td>考核周期:</td>
        <td>
          <el-date-picker
            value-format="yyyy-MM-dd"
            type="date"
            v-model="applyTime"
            :disabled="$route.query.from !== 'new'"
            placeholder="考核周期">
          </el-date-picker>
        </td>
        <td>部门:</td>
        <td width="400">
          <el-select v-model="department" :disabled="$route.query.from != 'new'" placeholder="请选择">
            <el-option
              v-for="item in departments"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </td>
        <td>姓名:</td>
        <td>
          <el-select v-model="value" style="width:60%" :disabled="$route.query.from != 'new'" placeholder="请选择"  @change="selectStaff($event)">
            <el-option
              v-for="item in staff"
              :key="item.value"
              :label="item.label"
              :value="item">
            </el-option>
          </el-select>
        </td>
        <td>岗位:<span style="display:inline-block;width:100px;padding-left:10px;"><el-input v-model="gangwei" :disabled="$route.query.from !== 'new'" placeholder="岗位"/></span></td>
      </tr>
      <tr>
        <td class="_name">考核指标</td>
        <td class="_name">指标定义</td>
        <td class="_name">权重</td>
        <td class="_name">评分说明</td>
        <td class="_name">数据来源</td>
        <td class="_name">自评</td>
        <td class="_name">评估得分</td>
        <!-- <td class="_name">扣分事项说明</td> -->
      </tr>
      <tr>
        <td rowspan="3">HR</td>
        <td>招聘</td>
        <td>60%</td>
        <td>
          根据公司经营需求，每月刷选简历200份，单月邀约到面人数40人,定期提供招聘相关报表:累 计年度员工流失率（不含试用期离职)不超过15%;确定需求岗位人员在一个月内完成招聘:每 月提出招聘合理化建议（-周内完成+4分，二周内完成+2分，超时--次扣2分:员工流失率15% &lt;R&lt;20%扣2分，R&gt;20%扣4分)</td>
        <td>直属上级</td>
        <td><el-input v-model="obj.a1057" :disabled="obj.a1057Flag" /></td>
        <td><el-input v-model="obj.a1064" :disabled="obj.a1064Flag" /></td>
      </tr>
      <tr>
        <td>考勤/异动</td>
        <td>15%</td>
        <td>
          每月6日前完成子公司考勤统计.异动薪资（出错一次扣1分）；在一天内反馈员工申诉事宜（超时-天扣1分)</td>
        <td>直属上级</td>
        <td><el-input v-model="obj.a1058" :disabled="obj.a1058Flag" /></td>
        <td><el-input v-model="obj.a1065" :disabled="obj.a1065Flag" /></td>
      </tr>
      <tr>
        <td>员工关系</td>
        <td>15%</td>
        <td>在员工入（离)职2个工作日内办理入（离)职手续、劳动合同、试岗协议、社保、员工花名册及钉钉档案管理等用工事项（出错--次扣2分)</td>
        <td>直属上级</td>
        <td><el-input v-model="obj.a1059" :disabled="obj.a1059Flag" /></td>
        <td><el-input v-model="obj.a1066" :disabled="obj.a1066Flag" /></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>日常事务</td>
        <td>5%</td>
        <td>依计划按时保质完成日常交办的人事工作</td>
        <td>直属上级</td>
        <td><el-input v-model="obj.a1060" :disabled="obj.a1060Flag" /></td>
        <td>
          <el-input v-model="obj.a1067" :disabled="obj.a1067Flag" />
        </td>
      </tr>
      <tr>
        <td>公司制度执行</td>
        <td>遵守公司规章制度</td>
        <td>5%</td>
        <td>对公司制度及公司文化的理解和执行。目标与时间管理.事必有复复必有时。</td>
        <td>督导</td>
        <td><el-input v-model="obj.a1061" :disabled="obj.a1061Flag" /></td>
        <td><el-input v-model="obj.a1068" :disabled="obj.a1068Flag" /></td>
      </tr>
      <tr>
        <td rowspan="2">加分项</td>
        <td>增量工作内容</td>
        <td>&nbsp;</td>
        <td>超出岗位职责范围、领导交办较为繁杂的事务、工作表现卓越等</td>
        <td>总经理</td>
        <td><el-input v-model="obj.a1062" :disabled="obj.a1062Flag" /></td>
        <td><el-input v-model="obj.a1069" :disabled="obj.a1069Flag" /></td>
      </tr>
      <tr>
        <td>对公司的建议</td>
        <td>&nbsp;</td>
        <td>对市场拓展、业务销售、内部管理等建设性意见</td>
        <td>总经理</td>
        <td><el-input v-model="obj.a1063" :disabled="obj.a1063Flag" /></td>
        <td><el-input v-model="obj.a1070" :disabled="obj.a1070Flag" /></td>
      </tr>
      <tr>
        <td colspan="5"></td>
        <td>自评:{{myScore}}</td>
        <td>综合考核率:{{otherScore}}</td>
      </tr>
    </table>
    <history :process="process"></history>
    <files></files>
  </section>
</template>
<script>
import mixin from '@/mixins/index.js'
import history from '../service/components/process'
import files from '../service/components/files'
import { sum } from '@/utils/domUtils.js'
const obj = {}
for (let i = 1056; i <= 1072; i++) {
  obj[`a${i}`] = ''
  obj[`a${i}Flag`] = true
}
export default {
  mixins: [mixin],
  data () {
    return {
      reason: '',
      truename: '',
      department: '',
      flag: false,
      value: '',
      obj: JSON.parse(JSON.stringify(obj)),
      applyTime: '',
      gangwei: '',
      file_paths: [],
      file_names: [],
      field_ids: [],
      field_vals: [],
      autoField: []
    }
  },
  components: { history, files },
  props: ['curDepartment', 'userInfo', 'approve', 'staff', 'addDofield', 'departments', 'process'],
  computed: {
    uploadArr () {
      return this.$store.state.uploadArr
    },
    b1 () {
      const num = parseFloat((Number(this.obj.a213) + Number(this.obj.a214)) / 2).toFixed(2)
      return num
    },
    myScore () {
      const result = []
      for (let i = 1057; i <= 1063; i++) {
        if (this.obj[`a${i}`]) {
          result.push(this.obj[`a${i}`])
        }
      }
      return sum(result)
    },
    otherScore () {
      const result = []
      for (let i = 1064; i <= 1070; i++) {
        if (this.obj[`a${i}`]) {
          result.push(this.obj[`a${i}`])
        }
      }
      return sum(result)
    }
  },
  mounted () {
    this.$nextTick(() => {
      this.obj = JSON.parse(JSON.stringify(obj))
      if (this.$route.query.from === 'new') {
        this.disabled = true
      } else {
        this.infoFunc()
      }
      this.addDofieldRender()
    })
  },
  methods: {
  }
}
</script>
